package com.example.tingshu.config;

import com.mysql.cj.jdbc.MysqlDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;
import java.sql.SQLException;

@Configuration
public class AppConfig {
    @Bean
    public DataSource dataSource() throws SQLException {
        MysqlDataSource mysqlDataSource = new MysqlDataSource();
        mysqlDataSource.setServerName("127.0.0.1");
        mysqlDataSource.setPort(3306);
        mysqlDataSource.setUser("root");
        mysqlDataSource.setPassword("123456");
        mysqlDataSource.setUseSSL(false);
        mysqlDataSource.setDatabaseName("listenbook");
        mysqlDataSource.setCharacterEncoding("utf-8");
        mysqlDataSource.setServerTimezone("Asia/Shanghai");
        return mysqlDataSource;
    }
}
